package com.example.addressbook;

import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class people extends AppCompatActivity {
    Button call,text,back;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_people);
        call =findViewById(R.id.btncall);
        text =findViewById(R.id.btntext);//添加按钮
        back =findViewById(R.id.btnback);//添加按钮

        call.setOnClickListener(new mClick());
        text.setOnClickListener(new mClick());
        back.setOnClickListener(new mClick());

        Intent intent = getIntent();
        Bundle bundle = intent.getExtras();
        //主界面点击ListView中的一个Item跳转时


    }
    private  class mClick implements View.OnClickListener {

        @Override
        public void onClick(View v) {
            switch (v.getId()) {

                case R.id.btncall:
                    Toast.makeText(getApplicationContext(),"拨打电话",Toast.LENGTH_LONG).show();
                    Intent intent=new Intent();
                    intent.setAction(Intent.ACTION_CALL);
                    intent.setData(Uri.parse("tel:10086"));
                    startActivity(intent);

                case R.id.btntext:
                    intent = new Intent(Intent.ACTION_SENDTO);
                    intent.setData(Uri.parse("smsto:" +"10086"));
                    intent.putExtra("sms_body","");
                    startActivity(intent);
                    break;
                case R.id.btnback:
                    intent = new Intent(people.this,MainActivity.class);
                    startActivity(intent);

            }
        }
    }
}